package com.huadao.cart_ccs.experiment.addCell;

import com.huadao.cart_ccs.common.ExperimentStageManager;
import com.huadao.cart_ccs.common.ProjectManager;
import com.huadao.cart_ccs.greendao.GreenDaoManager;
import com.huadao.cart_ccs.greendao.entity.AddCell;
import com.huadao.cart_ccs.greendao.gen.AddCellDao;

import java.util.List;

public class AddCellPresenter extends IAddCellContract.IAddCellPresenter {
    private AddCellDao addCellDao;

    public AddCellPresenter(IAddCellContract.IAddCellView baseView) {
        attachView(baseView);
        addCellDao=GreenDaoManager.getInstance().getSession().getAddCellDao();
    }

    @Override
    void getAddCellHistory() {
        List<AddCell> addCellList= addCellDao.queryBuilder().where(AddCellDao.Properties.ProjectId.eq(ProjectManager.getInstance().getProjectId()),AddCellDao.Properties.StageId.eq(ExperimentStageManager.getInstance().getStageId())).orderAsc(AddCellDao.Properties.StartDate).list();
        baseView.onGetAddCellHistory(addCellList);
    }

    @Override
    void saveAddCell(AddCell addCell) {
        addCellDao.insert(addCell);
    }
}
